/*
 * @Descripttion: unTitle
 * @Author: yizheng.yuan
 * @Date: 2021-11-08 09:01:59
 * @LastEditors: yizheng.yuan
 * @LastEditTime: 2021-11-08 11:11:14
 */
const Router = require('koa-router')

const userRouter = new Router({ prefix: '/user' })
const Admin = 'admin'

userRouter.post('/login', async ctx => {
  const user = ctx.request.body
  if (user.username === Admin && user.password === '123456') {
    ctx.session.user = {
      username: Admin
    }
    ctx.body = {
      success: true,
      data: {
        username: Admin
      }
    }
  } else {
    ctx.status = 400
    ctx.body = {
      success: false,
      message: 'username or password error'
    }
  }
})

module.exports = userRouter
